<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../css/07-discounts.css">
    <link rel="stylesheet" href="../css/media.css">
    <link rel="stylesheet" href="../css/Common.css">
    <title>07-discounts</title>
</head>

<body>
    <div class="discounts">
    </div>

    <div class="link">
       <a href="javascript:;">首页></a>
       <a href="javascript:;">优惠卷</a>
    </div>



</body>

</html>
<script src="../lib/jquery-1.12.4.min.js"></script>
<!-- 模板文件 -->
<script src="../js/template.js"></script>
<script type="text/template" id="title">
  {{each result as val key}}
  <div class="title">
       <a data-id="couponId" href="{{couponLink}}">
            <img src="{{val.couponImg}}" alt="">
            <div>{{val.couponTitle}}</div>
       </a>
    </div> 
  {{/each}}

</script>
<script>
    title();


    function title() {
        $.ajax({
            url: "http://193.112.55.79:9090/api/getcoupon",
            type: 'get',
            dataType: 'json',
            success: function (res1) {
                console.log(res1)
                template.config('escape', false)
                if (res1) {
                    var htmlStr1 = template('title', res1);
                    // console.log(htmlStr1);

                    //动态渲染数据
                    $('.discounts').html(htmlStr1);


                    // $('.title').change(function(){
                    //     shopid=$('.title').find('option:selected').attr('data-id')
                    //     // console.log($('.title').find('option:selected').attr('data-id'))
                    //     render(shopid,areaid)
                    // })

                }
            }
        })
    }
</script>